## function to format LaTeX output
hl2 <- function(dat, digits = 3, v)	{

	if(is.matrix(dat) != TRUE)	{ cat("matrix input needed!","\n","\n"); return(invisible()) }
	if(ncol(dat) != 2)	{ cat("Incorrect number of columns !","\n","\n"); return(invisible()) }

	if(all(is.na(dat))) { return(dat) }

	dat.new <- matrix(NA,nrow(dat), 2)

	for(m in 1:nrow(dat))	{

		sym <- ""
		tvalue <- abs(as.numeric(dat[m,1]) / as.numeric(dat[m,2]))

		if(tvalue >= qt(.95, v[m]))  sym <- "^{*}"
		if(tvalue >= qt(.975, v[m])) sym <- "^{**}"
		if(tvalue >= qt(.995, v[m])) sym <- "^{***}"

     	dat.new[m,1] <- 
     	paste("$", format(round(as.numeric(dat[m,1]), digits = digits),
     	scientific = FALSE, nsmall = digits), sym[], "$", sep = "")

     	dat.new[m,2] <- 
     	paste("$(", format(round(as.numeric(dat[m,2]), digits = digits),
     	scientific = FALSE, nsmall = digits),")$", sep = "")

							}

     	return(dat.new)
     }
